namespace C1.Win.C1FlexGrid.Util.Styles
{
    using System;
    using System.Drawing;

    internal class BorderMulti : BorderCompound
    {
        protected BorderMulti()
        {
        }

        public BorderMulti(Color color, int[] thickness)
        {
            if (thickness.Length < 3)
            {
                throw new ArgumentException("BorderMulti needs an array with at least three values.");
            }
            base._outer = new Border(color, thickness[0]);
            for (int i = 1; i < (thickness.Length - 1); i += 2)
            {
                base.AddInner(new BorderEmpty(thickness[i]));
                base.AddInner(new Border(color, thickness[i + 1]));
            }
        }

        public BorderMulti(Color color, int levels, int thickness)
        {
            this.BuildMultiBorder(color, levels, thickness, thickness);
        }

        public BorderMulti(Color color, int levels, int thickness, int spacing)
        {
            this.BuildMultiBorder(color, levels, thickness, spacing);
        }

        protected void BuildMultiBorder(Color color, int levels, int thickness, int spacing)
        {
            if (levels < 2)
            {
                throw new ArgumentException("BorderMulti needs at least two levels");
            }
            base._outer = new Border(color, thickness);
            while (levels > 1)
            {
                base.AddInner(new BorderEmpty(spacing));
                base.AddInner(new Border(color, thickness));
                levels--;
            }
        }
    }
}

